﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Arroguella.Utilities;

namespace Arroguella.Panels.Popups
{
    /// <summary>
    /// A single option in a popup menu
    /// </summary>
    public class PopupMenuOption : Panels.ScreenPanel
    {
        #region Constructor

        public PopupMenuOption(object option, Rectangle boundingRect, Color color, Game game) : base(game)
        {
            string text = option.ToString();
            Text = string.IsNullOrEmpty(text) ? "Unknown" : text;
            SetSizeAndShape(boundingRect.X, boundingRect.Y, boundingRect.Width, boundingRect.Height);

            HighlightColor = color;
        }

        public PopupMenuOption(string optionText, Rectangle boundingRect, Color color, Game game)
            : base(game)
        {
            Text = optionText;
            SetSizeAndShape(boundingRect.X, boundingRect.Y, boundingRect.Width, boundingRect.Height);

            HighlightColor = color;
        }

        #endregion

        #region Methods

        public override void Draw(SpriteBatch spriteBatch)
        {
            if (IsSelected)
            {
                Utils.DrawFilledRectangle(HighlightColor, SizeAndShape, spriteBatch, Arroguella.GraphicsDevice);
                Utils.DrawString(spriteBatch, Font, Text, Color.WhiteSmoke, SizeAndShape, Utils.Alignment.Left);
            }
            else
            {
                Utils.DrawString(spriteBatch, Font, Text, HighlightColor, SizeAndShape, Utils.Alignment.Left);
            }
        }

        #endregion

        #region Properties

        public bool IsSelected;

        public Color HighlightColor;

        public string Text;

        #endregion
    }
}
